#include "NetCDFReader.h"
#include "NcWrapper.h"

namespace OCPP
{
	NetCDFReader::NetCDFReader()
	{
		ncWrapper = std::make_unique<NcWrapper>();
	}

	NetCDFReader::~NetCDFReader()
	{

	}

	Json::Value NetCDFReader::getVars()
	{
		return ncWrapper->getVars();
	}

	bool NetCDFReader::open(String fileName, bool printDescription)
	{
		mFileName = fileName;
		bool isOpen = ncWrapper->open(fileName);
		if (isOpen && printDescription) {
			ncWrapper->print();
		}

		return isOpen;
	}

	void NetCDFReader::extract(String varName, const VolumeOptions& options, int levelIndex
		, int timeIndex)
	{
		ncWrapper->extract(varName, levelIndex, timeIndex, options);
	}

	void NetCDFReader::extract(VolumeComputeList computeList
		, std::shared_ptr<VolumeAlgorithm> ncAlgorithm
		, const VolumeOptions& options
		, int levelIndex
		, int timeIndex)
	{
		NcCompute compute;
		compute.setComputeList(computeList);
		compute.setAlgorithm(ncAlgorithm);
		compute.extract(levelIndex, timeIndex, options);
	}
}
